package me.sunsy.kit.test

interface Car {
    fun run()
}

class BenzCar : Car {
    override fun run() {
        println("奔驰汽车跑起来了")
    }
}

class BmwCar : Car {
    override fun run() {
        println("宝马汽车跑起来了")
    }
}

class AudiCar : Car {
    override fun run() {
        println("奥迪汽车跑起来了")
    }
}

open class CarDecorator constructor(protected val decorator: Car) : Car {
    override fun run() {
        decorator.run()
    }
}

class AutoCarDecorator constructor(private val car: Car) : CarDecorator(car) {

    override fun run() {
        decorator.run()
        autoRun()
    }

    private fun autoRun() {
        println("我会自动驾驶了")
    }

}

class FlyCarDecorator constructor(private val car: Car) : CarDecorator(car) {

    override fun run() {
        decorator.run()
        flyRun()
    }

    private fun flyRun() {
        println("我会飞了")
    }

}